Object::IsEqual

Section: ET++ method description (n)
Updated: automatically Fri Mar 1 10:54:57 1991
Index Return to Main Contents
 

NAME

Object::IsEqual - instance method  

TEMPLATE

objectsAreEqual = bool IsEqual(ObjPtr anObject)  

SPECIFIERS

public virtual  

DESCRIPTION

IsEqual checks whether this and anObject are equal.
The default implementation simply compares the memory addresses of the two objects. This means it checks whether this and anObject are identical.
IsEqual should be overridden if objects are put in collections (see class Collection).
The typical implementation first checks by means of the macro IsKindOf or the method IsA whether anObject is of the same class as this. Then it compares the objects based on the values of some instance variables. See also method Compare and method Hash.
Examples
method ByteArray::IsEqual, method ObjInt::IsEqual, method VObject::IsEqual, method Collection::IsEqual. Method is often overridden.  

ARGUMENTS

ObjPtr anObject

the object to be compared with the receiver
 

RETURN ARGUMENT

bool objectsAreEqual

is TRUE
if this is equal to anObject
 

CATEGORIES

comparison, collection support, client interface, overrider interface

 

FIRST DEFINITION

class Object  

FILES

implementation:
Object.C

 

KNOWN PROBLEMS

1. IsEqual is not guaranteed to be commutative: calling IsEqual for two objects may lead to different results because the objects can be of different classes with different implementations of this method. Commutativity is guaranteed only if every implementation of IsEqual assures that both objects are of the same class (e.g.

IsA() ==
anObject->IsA()
). In ET++ however, most implementations check the class with the macro IsKindOf. In this case commutativity is not guaranteed if the classes of the objects are in a superclass/subclass relationship and the subclass overrides this method.
2. Sometimes more than one kind of equality is required.
3. Implementing IsEqual and method Compare very often requires duplication of code.


 

Index

NAME
TEMPLATE
SPECIFIERS
DESCRIPTION
ARGUMENTS
RETURN ARGUMENT
CATEGORIES
FIRST DEFINITION
FILES
KNOWN PROBLEMS

This document was created by man2html, using the manual pages.
Time: 00:40:25 GMT, March 30, 2022